<!--角色管理页-->
<template>
  <ex_super_table_page v-bind="option" class="page-container" ref="SuperTablePage">
  </ex_super_table_page>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';

export default {

  title: 'title_role_manage',
  mixins: [superTablePageFunction],
  components: {},

  data() {
    return {
      option: {
        search: {
          model: [
            { label: "label_role_name", key: "roleName", },
            {
              if: function () { return false },
              key: 'customerName',
              label: 'label_belong_company'
            },
            {

              label: "label_status", key: "status", type: 'select', enum: 'IsAvailableStatusEnum'
            },
          ],
        },
        action: [
          {
            label: "label_add_role", attrs: { icon: "el-icon-plus" }, click: () => {

              this.$router.push({
                path: this.editPagePath,
                query: {}
              })

            }
          },
        ],

        table: {
          url: "/ums-api/user/UserRoleRpc/select.json?roleScope=" + this.roleScope + "&roleSystem=" + this.roleSystem,
          model: [
            { key: 'name', label: 'label_role_name', align: 'left' },
            { key: 'roleSystem', label: 'label_applicable_system', align: 'left' },
            {
              width: 200,
              key: 'roleType', label: 'label_fms_service_code_type', align: 'left', attrs: {
                formatter: (r, c, v, i) => {
                  return '[' + (r.roleSystem) + '] ' + ((r.roleType == 'ADMIN') ? this.$tt('label_admin_user') : this.$tt('label_operator_user')) + ((r.roleScope == 'DEFAULT') ? ` - ${this.$tt('label_default')}` : '')
                }
              }
            },
            // { key: 'customerName', label: '所属公司'  },
            { key: 'remark', label: 'label_remark', align: 'left' },
            {
              key: 'status', label: 'label_status', attrs: {
                formatter: (r, c, v, i) => this.$enumShow(v, 'IsAvailableStatusEnum')
              }
            },
            { key: 'creator', label: 'label_create_user', align: 'left' },
            { key: 'gmtCreate', label: 'label_create_time', attrs: { formatter: (r, c, v, i) => this.$dateFormat(v) }, },
            { key: 'modifier', label: 'label_modify_user' },
            {
              key: 'gmtModify', label: 'label_modify_time', attrs: {
                formatter: (r, c, v, i) => {
                  return this.$dateFormat(v)
                }
              }
            },
            {
              type: 'operate', width: 160, operate: [
                {
                  label: "label_edit", click: (row) => {

                    this.$router.push({
                      path: this.editPagePath,
                      query: { id: row.id }
                    })
                  }
                },
                {
                  label: "label_start_using",
                  type: 'confirm-button',
                  url: '/ums-api/user/UserRoleRpc/changeStatus.json',
                  message: 'label_fms_bank_card_confirm_enable',
                  if: row => !row.status || row.status == 'DISABLED',
                  params: (row) => {
                    return { id: row.id, status: 'ENABLE' }
                  },
                  done: ['reload', 'tip']
                },
                {
                  label: "label_stop_using",
                  type: 'confirm-button',
                  url: '/ums-api/user/UserRoleRpc/changeStatus.json',
                  message: 'label_fms_bank_card_confirm_forbidden',
                  if: row => row.status == 'ENABLE' ,
                  buttonClass: "button_text_danger", confirmButtonType: 'danger',
                  params: (row) => {
                    return { id: row.id, status: 'DISABLED' }
                  },
                  done: ['reload', 'tip']
                },

                {
                  label: "label_delete",
                  type: 'confirm-button',
                  url: '/ums-api/user/UserRoleRpc/remove.json',
                  message: 'label_fms_bank_card_confirm_delete',
                  buttonClass: "button_text_danger", confirmButtonType: 'danger',
        
                  params: (row) => {
                    return { id: row.id }
                  },
                  done: ['reload', 'tip']
                },

              ],
            }
          ],

        }
        ,

      },


    };
  },


  props: {
    'editPagePath': {
      type: String,
      default: ''
    },

    // admin  compnay
    'roleScope': {
      type: String,
      defafult: ''
    },

    // WMS OMS TMS
    'roleSystem': {
      type: String,
      defafult: ''
    }

  },


  created() {


  },

  destroyed() {
  },


  methods: {

  }
};

</script>
<style></style>
